<script src="__PUBLIC__/js/bootstrap.js"></script>
<script src="__PUBLIC__/js/jquery.nanoscroller.min.js"></script>
<script src="__PUBLIC__/js/pace.min.js"></script>

<script src="__PUBLIC__/js/hopscotch.js"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/hopscotch.css">
<script src="__PUBLIC__/js/cookies.js"></script>
<script src="__PUBLIC__/js/messager.js"></script>
<script src="__JS__/app.js"></script>
<script type="text/javascript">
function isMobile() {
	var userAgentInfo = navigator.userAgent;

	var mobileAgents = [ "Android", "iPhone", "SymbianOS", "Windows Phone", "iPad","iPod"];

	var mobile_flag = false;

	//根据userAgent判断是否是手机
	for (var v = 0; v < mobileAgents.length; v++) {
		if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
			mobile_flag = true;
			break;
		}
	}

		var screen_width = window.screen.width;
		var screen_height = window.screen.height;    

		//根据屏幕分辨率判断是否是手机
		if(screen_width < 500 && screen_height < 800){
			mobile_flag = true;
		}

		return mobile_flag;
}

(function(){
	if (!isMobile())
	{
		$('#sidebar-nav .active').parent().slideDown('200')
		$('#sidebar-nav .active').parent().parent().addClass('open');
	}
	
	
	var SentCMS = window.Sent = {
		"ROOT"   : "__ROOT__", //当前网站地址
		"APP"    : "__APP__", //当前项目地址
		"PUBLIC" : "__PUBLIC__", //项目公共目录地址
		"DEEP"   : "{:config('URL_PATHINFO_DEPR')}", //PATHINFO分割符
		"MODEL"  : ["{:config('URL_MODEL')}", "{:config('URL_CASE_INSENSITIVE')}", "{:config('URL_HTML_SUFFIX')}"],
		"VAR"    : ["{:config('VAR_MODULE')}", "{:config('VAR_CONTROLLER')}", "{:config('VAR_ACTION')}"]
	}

})();
var dragModal = {
        mouseStartPoint: { "left": 0, "top": 0 },
        mouseEndPoint: { "left": 0, "top": 0 },
        mouseDragDown: false,
        basePoint: { "left": 0, "top": 0 },
        moveTarget: null,
        topleng: 0
    }
    $(document).on("mousedown", ".modal-header", function (e) {
        //webkit内核和火狐禁止文字被选中
        $('body').addClass('select')
        //ie浏览器禁止文字选中
        document.body.onselectstart = document.body.ondrag = function () {
            return false;
        }
        if ($(e.target).hasClass("close"))//点关闭按钮不能移动对话框  
            return;
        dragModal.mouseDragDown = true;
        dragModal.moveTarget = $(this).parent().parent();
        dragModal.mouseStartPoint = { "left": e.clientX, "top": e.pageY };
        dragModal.basePoint = dragModal.moveTarget.offset();
        dragModal.topLeng = e.pageY - e.clientY;
    });
    $(document).on("mouseup", function (e) {
        dragModal.mouseDragDown = false;
        dragModal.moveTarget = undefined;
        dragModal.mouseStartPoint = { "left": 0, "top": 0 };
        dragModal.basePoint = { "left": 0, "top": 0 };
    });
    $(document).on("mousemove", function (e) {
        if (!dragModal.mouseDragDown || dragModal.moveTarget == undefined) return;
        var mousX = e.clientX;
        var mousY = e.pageY;
        if (mousX < 0) mousX = 0;
        if (mousY < 0) mousY = 25;
        dragModal.mouseEndPoint = { "left": mousX, "top": mousY };
        var width = dragModal.moveTarget.width();
        var height = dragModal.moveTarget.height();
        var clientWidth = document.body.clientWidth
        var clientHeight = document.body.clientHeight;
        if (dragModal.mouseEndPoint.left < dragModal.mouseStartPoint.left - dragModal.basePoint.left) {
            dragModal.mouseEndPoint.left = 0;
        }
        else if (dragModal.mouseEndPoint.left >= clientWidth - width + dragModal.mouseStartPoint.left - dragModal.basePoint.left) {
            dragModal.mouseEndPoint.left = clientWidth - width ;
        } else {
            dragModal.mouseEndPoint.left = dragModal.mouseEndPoint.left - (dragModal.mouseStartPoint.left - dragModal.basePoint.left);//移动修正，更平滑  

        }
        if (dragModal.mouseEndPoint.top - (dragModal.mouseStartPoint.top - dragModal.basePoint.top) < dragModal.topLeng) {
            dragModal.mouseEndPoint.top = dragModal.topLeng;
        } else if (dragModal.mouseEndPoint.top - dragModal.topLeng > clientHeight - height + dragModal.mouseStartPoint.top - dragModal.basePoint.top) {
            dragModal.mouseEndPoint.top = clientHeight - height - 38 + dragModal.topLeng;
        }
        else {
            dragModal.mouseEndPoint.top = dragModal.mouseEndPoint.top - (dragModal.mouseStartPoint.top - dragModal.basePoint.top);
        }
        dragModal.moveTarget.offset(dragModal.mouseEndPoint);
    });
    $(document).on('hidden.bs.modal', '.modal', function (e) {
        $('.modal-dialog').css({ 'top': '0px', 'left': '0px' })
        $('body').removeClass('select')
        document.body.onselectstart = document.body.ondrag = null;
    })
</script>
<script src="__PUBLIC__/js/core.js?times={:time()}"></script>

</body>
</html>